function [mom] = getmom(ann_sale,ann_price, ann_purchase) 
%              1   2  3  4  5  6  7 8  9  10 11 12 13
     pctuse = [99 95 90 85 80 75 70 25 20 15 10 5 1];
     
     ln1quan = log(ann_purchase+1);
     ln1quanave = nanmean(nanmean(log(ann_purchase+1)));
     ln1quansd = nanmean(nanstd(log(ann_purchase+1)));
     
      lnquan = log(ann_purchase);
      lnquan(lnquan==-Inf) = nan;
     lnquanave = nanmean(nanmean(log(ann_purchase)));
     lnquansd = nanmean(nanstd(log(ann_purchase)));
     
     ln1rev = log(ann_sale+1);
     ln1rev99h = ln1rev; ln1rev95h = ln1rev; ln1rev90h = ln1rev; ln1rev85h = ln1rev; ln1rev80h = ln1rev; ln1rev75h = ln1rev; ln1rev70h = ln1rev;
     ln1rev99l = ln1rev; ln1rev95l = ln1rev; ln1rev90l = ln1rev; ln1rev85l = ln1rev; ln1rev80l = ln1rev; ln1rev75l = ln1rev; ln1rev70l = ln1rev;
     pctln1rev = prctile(ln1rev,pctuse);
     ln1rev7525 = pctln1rev(6,:)./pctln1rev(8,:);
    ln1rev8020 = pctln1rev(5,:)./pctln1rev(9,:);
    ln1rev8515 = pctln1rev(4,:)./pctln1rev(10,:);
    ln1rev9010 = pctln1rev(3,:)./pctln1rev(11,:);
    ln1rev9505 = pctln1rev(2,:)./pctln1rev(12,:);
    ln1rev9901 = pctln1rev(1,:)./pctln1rev(13,:);
     ln1rev7525 = nanmean(ln1rev7525(isfinite(ln1rev7525)));
     ln1rev8020 = nanmean(ln1rev8020(isfinite(ln1rev8020)));
     ln1rev8515 = nanmean(ln1rev8515(isfinite(ln1rev8515)));
     ln1rev9010 = nanmean(ln1rev9010(isfinite(ln1rev9010)));
     ln1rev9505 = nanmean(ln1rev9505(isfinite(ln1rev9505)));
     ln1rev9901 = nanmean(ln1rev9901(isfinite(ln1rev9901)));
     ln1revave = nanmean(nanmean(log(ann_sale+1)));
     ln1revsd = nanmean(nanstd(log(ann_sale+1)));
     ln1revcv = ln1revave/ln1revsd;
     ln1rev99h(find((log(ann_sale+1)>repmat(pctln1rev(1,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev95h(find((log(ann_sale+1)>repmat(pctln1rev(2,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev90h(find((log(ann_sale+1)>repmat(pctln1rev(3,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev85h(find((log(ann_sale+1)>repmat(pctln1rev(4,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev80h(find((log(ann_sale+1)>repmat(pctln1rev(5,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev75h(find((log(ann_sale+1)>repmat(pctln1rev(6,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev70h(find((log(ann_sale+1)>repmat(pctln1rev(7,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev99l(find((log(ann_sale+1)<=repmat(pctln1rev(1,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev95l(find((log(ann_sale+1)<=repmat(pctln1rev(2,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev90l(find((log(ann_sale+1)<=repmat(pctln1rev(3,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev85l(find((log(ann_sale+1)<=repmat(pctln1rev(4,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev80l(find((log(ann_sale+1)<=repmat(pctln1rev(5,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev75l(find((log(ann_sale+1)<=repmat(pctln1rev(6,:),size(ann_sale,1),1))==0)) = nan;
     ln1rev70l(find((log(ann_sale+1)<=repmat(pctln1rev(7,:),size(ann_sale,1),1))==0)) = nan;
     
     pctsale = prctile(ann_sale,pctuse);
     rev99h = ann_sale;rev95h = ann_sale;rev90h = ann_sale;rev85h = ann_sale;rev80h = ann_sale;rev75h = ann_sale;rev70h = ann_sale;
     rev99l = ann_sale;rev95l = ann_sale;rev90l = ann_sale;rev85l = ann_sale;rev80l = ann_sale;rev75l = ann_sale;rev70l = ann_sale;
     rev99h(find((ann_sale>repmat(pctsale(1,:),size(ann_sale,1),1))==0)) = nan;
     rev95h(find((ann_sale>repmat(pctsale(2,:),size(ann_sale,1),1))==0)) = nan;
     rev90h(find((ann_sale>repmat(pctsale(3,:),size(ann_sale,1),1))==0)) = nan;
     rev85h(find((ann_sale>repmat(pctsale(4,:),size(ann_sale,1),1))==0)) = nan;
     rev80h(find((ann_sale>repmat(pctsale(5,:),size(ann_sale,1),1))==0)) = nan;
     rev75h(find((ann_sale>repmat(pctsale(6,:),size(ann_sale,1),1))==0)) = nan;
     rev70h(find((ann_sale>repmat(pctsale(7,:),size(ann_sale,1),1))==0)) = nan;
     rev99l(find((ann_sale<=repmat(pctsale(1,:),size(ann_sale,1),1))==0)) = nan;
     rev95l(find((ann_sale<=repmat(pctsale(2,:),size(ann_sale,1),1))==0)) = nan;
     rev90l(find((ann_sale<=repmat(pctsale(3,:),size(ann_sale,1),1))==0)) = nan;
     rev85l(find((ann_sale<=repmat(pctsale(4,:),size(ann_sale,1),1))==0)) = nan;
     rev80l(find((ann_sale<=repmat(pctsale(5,:),size(ann_sale,1),1))==0)) = nan;
     rev75l(find((ann_sale<=repmat(pctsale(6,:),size(ann_sale,1),1))==0)) = nan;
     rev70l(find((ann_sale<=repmat(pctsale(7,:),size(ann_sale,1),1))==0)) = nan;
     
    ln1revratio70 = nanmean(nanmean(ln1rev70h)./nanmean(ln1rev70l));
    ln1revratio75 = nanmean(nanmean(ln1rev75h)./nanmean(ln1rev75l));
    ln1revratio80 = nanmean(nanmean(ln1rev80h)./nanmean(ln1rev80l));
    ln1revratio85 = nanmean(nanmean(ln1rev85h)./nanmean(ln1rev85l));
    ln1revratio90 = nanmean(nanmean(ln1rev90h)./nanmean(ln1rev90l));
    ln1revratio95 = nanmean(nanmean(ln1rev95h)./nanmean(ln1rev95l));
    ln1revratio99 = nanmean(nanmean(ln1rev99h)./nanmean(ln1rev99l));
    
     pctlnprice = prctile(log(ann_price),pctuse);
     lnprice7525 = nanmean(pctlnprice(6,:)./pctlnprice(8,:));
     lnprice8020 = nanmean(pctlnprice(5,:)./pctlnprice(9,:));
     lnprice8515 = nanmean(pctlnprice(4,:)./pctlnprice(10,:));
     lnprice9010 = nanmean(pctlnprice(3,:)./pctlnprice(11,:));
     lnprice9505 = nanmean(pctlnprice(2,:)./pctlnprice(12,:));
     lnprice9901 = nanmean(pctlnprice(1,:)./pctlnprice(13,:));
     lnpriceave = nanmean(nanmean(log(ann_price)));
     lnpricesd = nanmean(nanstd(log(ann_price)));
     lnpricecv = lnpriceave/lnpricesd;
     
     lnann_sale = log(ann_sale);
     lnann_sale(find(lnann_sale==-Inf)) = nan;
     pctlnrev = prctile(lnann_sale,pctuse);
     lnrev7525 = nanmean(pctlnrev(6,:)./pctlnrev(8,:));
     lnrev8020 = nanmean(pctlnrev(5,:)./pctlnrev(9,:));
     lnrev8515 = nanmean(pctlnrev(4,:)./pctlnrev(10,:));
     lnrev9010 = nanmean(pctlnrev(3,:)./pctlnrev(11,:));
     lnrev9505 = nanmean(pctlnrev(2,:)./pctlnrev(12,:));
     lnrev9901 = nanmean(pctlnrev(1,:)./pctlnrev(13,:));
     lnrevave = nanmean(nanmean(lnann_sale));
     lnrevsd = nanmean(nanstd(lnann_sale));
     lnrevcv = lnrevave/lnrevsd;
     
     pctlnsale = prctile(lnann_sale,pctuse);
     lnrev99h = lnann_sale; lnrev95h = lnann_sale; lnrev90h = lnann_sale; lnrev85h = lnann_sale; lnrev80h = lnann_sale; lnrev75h = lnann_sale; lnrev70h = lnann_sale;
     lnrev99l = lnann_sale; lnrev95l = lnann_sale; lnrev90l = lnann_sale; lnrev85l = lnann_sale; lnrev80l = lnann_sale; lnrev75l = lnann_sale; lnrev70l = lnann_sale;
     lnrev99h(find((lnann_sale>repmat(pctlnsale(1,:),size(ann_sale,1),1))==0))=nan;
     lnrev95h(find((lnann_sale>repmat(pctlnsale(2,:),size(ann_sale,1),1))==0))=nan;
     lnrev90h(find((lnann_sale>repmat(pctlnsale(3,:),size(ann_sale,1),1))==0))=nan;
     lnrev85h(find((lnann_sale>repmat(pctlnsale(4,:),size(ann_sale,1),1))==0))=nan;
     lnrev80h(find((lnann_sale>repmat(pctlnsale(5,:),size(ann_sale,1),1))==0))=nan;
     lnrev75h(find((lnann_sale>repmat(pctlnsale(6,:),size(ann_sale,1),1))==0))=nan;
     lnrev70h(find((lnann_sale>repmat(pctlnsale(7,:),size(ann_sale,1),1))==0))=nan;
     lnrev99l(find((lnann_sale>repmat(pctlnsale(1,:),size(ann_sale,1),1))==0))=nan;
     lnrev95l(find((lnann_sale<=repmat(pctlnsale(2,:),size(ann_sale,1),1))==0))=nan;
     lnrev90l(find((lnann_sale<=repmat(pctlnsale(3,:),size(ann_sale,1),1))==0))=nan;
     lnrev85l(find((lnann_sale<=repmat(pctlnsale(4,:),size(ann_sale,1),1))==0))=nan;
     lnrev80l(find((lnann_sale<=repmat(pctlnsale(5,:),size(ann_sale,1),1))==0))=nan;
     lnrev75l(find((lnann_sale<=repmat(pctlnsale(6,:),size(ann_sale,1),1))==0))=nan;
     lnrev70l(find((lnann_sale<=repmat(pctlnsale(7,:),size(ann_sale,1),1))==0))=nan;
     
    lnrevratio70 = nanmean(nanmean(lnrev70h)./nanmean(lnrev70l));
    lnrevratio75 = nanmean(nanmean(lnrev75h)./nanmean(lnrev75l));
    lnrevratio80 = nanmean(nanmean(lnrev80h)./nanmean(lnrev80l));
    lnrevratio85 = nanmean(nanmean(lnrev85h)./nanmean(lnrev85l));
    lnrevratio90 = nanmean(nanmean(lnrev90h)./nanmean(lnrev90l));
    lnrevratio95 = nanmean(nanmean(lnrev95h)./nanmean(lnrev95l));
    lnrevratio99 = nanmean(nanmean(lnrev99h)./nanmean(lnrev99l));

    revratio70 = nanmean(nanmean(rev70h)./nanmean(rev70l));
    revratio75 = nanmean(nanmean(rev75h)./nanmean(rev75l));
    revratio80 = nanmean(nanmean(rev80h)./nanmean(rev80l));
    revratio85 = nanmean(nanmean(rev85h)./nanmean(rev85l));
    revratio90 = nanmean(nanmean(rev90h)./nanmean(rev90l));
    revratio95 = nanmean(nanmean(rev95h)./nanmean(rev95l));
    revratio99 = nanmean(nanmean(rev99h)./nanmean(rev99l));

    revshare70 = nanmean(nansum(rev70h)./nansum(ann_sale));
    revshare75 = nanmean(nansum(rev75h)./nansum(ann_sale));
    revshare80 = nanmean(nansum(rev80h)./nansum(ann_sale));
    revshare85 = nanmean(nansum(rev85h)./nansum(ann_sale));
    revshare90 = nanmean(nansum(rev90h)./nansum(ann_sale));
    revshare95 = nanmean(nansum(rev95h)./nansum(ann_sale));
    revshare99 = nanmean(nansum(rev99h)./nansum(ann_sale));

     sumrev = nansum(nansum(ann_sale));
     mom = [revshare99;
revshare95;
revshare90;
revshare85;
revshare80;
revshare75;
revshare70;
revratio99;
revratio95;
revratio90;
revratio85;
revratio80;
revratio75;
revratio70;
lnrevratio99;
lnrevratio95;
lnrevratio90;
lnrevratio85;
lnrevratio80;
lnrevratio75;
lnrevratio70;
ln1revratio99;
ln1revratio95;
ln1revratio90;
ln1revratio85;
ln1revratio80;
ln1revratio75;
ln1revratio70;
lnpriceave;
lnrevave;
ln1revave;
lnpricesd;
lnrevsd;
ln1revsd;
lnpricecv;
lnrevcv;
ln1revcv;
lnprice9901;
lnprice9505;
lnprice9010;
lnprice8515;
lnprice8020;
lnprice7525;
lnrev9901;
lnrev9505;
lnrev9010;
lnrev8515;
lnrev8020;
lnrev7525;
ln1rev9901;
ln1rev9505;
ln1rev9010;
ln1rev8515;
ln1rev8020;
ln1rev7525;
sumrev];
% mom = [lnpriceave;lnpricesd;ln1revave;ln1revsd;ln1quanave;ln1quansd];
% lnpricesd = lnpricesd*10;
%ln1revave =ln1revave*10;
%  mom = [lnpriceave;lnpricesd;ln1revave;ln1revsd];
mom = [sumrev;revshare99;revshare95];
end